/*
* @Author: yanyanru
* @Date: 2018/4/13
* @description: 募集信息
*/
<template>
    <div class='custom-box m-t-20 p-20'>
        <div class="custom-title">
            <h3 class="m-r-10">募集信息</h3>
            <div class='m-l-10'><el-button type="primary" round size='mini' @click="saveFundCollect">保存</el-button></div>
        </div>
        <el-form label-width="100px" class="m-t-20">
            <el-row>
                <el-col :span="6">
                    <el-form-item label="开始募集时间 " label-width="130px">
                        <el-date-picker 
                        v-model="comFundCollect.startTime"
                        type="date"  placeholder="选择日期" style="width:100%"></el-date-picker>
                    </el-form-item>
                </el-col>
                <el-col :span="6">
                    <el-form-item label="目标募集规模" label-width="130px">
                        <el-input style="width:100%" v-model="comFundCollect.targetCollection">
                            <template slot="append">万</template>
                        </el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="4" :offset="1">
                    <el-form-item  label-width="0" style="margin-top: -1px">
                        <el-select style="width:100%" v-model="comFundCollect.startCurrencyType">
                        <el-option
                            v-for="item in currencyType"
                            :key="item.id"
                            :label="item.dictName"
                            :value="item.dictValue-0">
                        </el-option>
                        </el-select>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="12">
                    <el-form-item label="开始募集中文介绍" label-width="130px">
                            <el-input  type="textarea" :rows="4" :maxlength="2000"
                                v-model="comFundCollect.startCollectionCn"
                                resize="none"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="开始募集英文介绍" label-width="130px">
                        <el-input 
                            v-model="comFundCollect.startCollectionEn" 
                            type="textarea" 
                            :rows="4" :maxlength="2000"
                            resize="none"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>    
            <el-row>
                <el-col :span="6">
                    <el-form-item label="最终募集时间 " label-width="130px">
                        <el-date-picker
                            v-model="comFundCollect.finallyTime" 
                            type="date" placeholder="选择日期"
                            style="width:100%"></el-date-picker>
                    </el-form-item>
                </el-col>
                <el-col :span="6">
                    <el-form-item label="最终募集规模" label-width="130px">
                        <el-input style="width:100%" v-model="comFundCollect.finallyScale">
                            <template slot="append">万</template>
                        </el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="4" :offset="1">
                    <el-form-item label=""  label-width="0" style="margin-top: -1px">
                        <el-select  style="width:100%" v-model="comFundCollect.finallyCurrencyType">
                            <el-option
                                v-for="item in currencyType"
                                :key="item.id"
                                :label="item.dictName"
                                :value="item.dictValue-0">
                            </el-option>    
                        </el-select>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="12">
                    <el-form-item label="最终募集中文介绍" label-width="130px">
                        <el-input
                            v-model="comFundCollect.finallyCnDesc"  
                            type="textarea" :rows="4" :maxlength="2000"
                                    resize="none"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="最终募集英文介绍"  label-width="130px">
                        <el-input
                            v-model="comFundCollect.finallyEnDesc"
                            type="textarea" :rows="4" :maxlength="2000"
                            resize="none"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
    </el-form>
  </div>
</template>
<script lang="ts">
import Vue from 'vue';
import { Component, Watch, Prop } from 'vue-property-decorator';
import ComFundService from '../../../../../service/subject/company/fund-info/index';
import { ComFundCollectDto, } from '../../../../../api/Interface';
@Component({
  components: { }
})
export default class BasicInfo extends Vue {
    @Prop({})
    public fundId: number;
    // 初始化数据 相当于data
    public currencyType: object[] = this.$store.state.user.dictionary.dicList.currencyType;
    public comFundCollect: ComFundCollectDto = {} as ComFundCollectDto;
    
    // refs
    public $refs: { };

    // watch
    @Watch('fundId')
    public onChildChanged(val: number, oldVal: number) {
        this.fundId = val;
    }
    // 声明周期钩子
    public created() {
        this.getFundCollect(Number(this.$route.params.itemId));
    }
    // 保存
    public async saveFundCollect() {
        this.comFundCollect.companyId = Number(this.$route.params.itemId);
        this.comFundCollect.fundId = this.fundId;
        if (!this.comFundCollect.id) { // 添加
            const { resCode } = await ComFundService.saveComFundCollect(this.comFundCollect);
            if (resCode === '0') {
                this.$message.success('添加成功');
                this.getFundCollect(Number(this.$route.params.itemId));
            }
        } else { // 修改
            const { resCode } = await ComFundService.updateComFundCollect(this.comFundCollect);
            if (resCode === '0') {
                this.$message.success('修改成功');
            }
        }
    }
    public async getFundCollect(id: number) {
        const res = await ComFundService.getComFundCollectById(id);
        this.comFundCollect = res.data;
    }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>

</style>